package com.onepower.admin.controller;


import com.onepower.core.modules.repository.entity.MatchPlace;
import com.onepower.core.modules.repository.entity.TkdMatch;
import com.onepower.core.modules.service.IMatchPlaceService;
import com.onepower.core.result.CommonResult;
import com.onepower.core.utils.ResultUtils;
import com.onepower.core.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 比赛场地表 前端控制器
 * </p>
 *
 * @author kin
 * @since 2018-08-06
 */
@RestController
@RequestMapping("/api/matchPlace")
public class MatchPlaceController {


    @Autowired
    private IMatchPlaceService matchPlaceService;

    @RequestMapping(value = "list", method = RequestMethod.GET)
    public CommonResult getMatchInfo(@RequestParam(value = "matchId") Integer matchId) {
        List<MatchPlace> matchPlaceList = matchPlaceService.getListByMatchId(matchId);
        return ResultUtils.ok(matchPlaceList);
    }

    @RequestMapping(value = "save", method = RequestMethod.POST)
    public CommonResult save(@RequestBody MatchPlace matchPlace) {
        matchPlace.setCreaterId(SecurityUtils.getCurrentUserId());
        matchPlaceService.save(matchPlace);
        return ResultUtils.ok();
    }
}
